<script>
<!--
var sort_by = '';
var sort_order = 0;
var current_view = '';
var page = 1;

function listReload(page)
{
    $('#indexAjax').html('<div align="center"><div class="loader_admin"></div></div>');
    $('#indexAjax').load('<?php echo url_for('@cms_category_list') ?>?'+$('#filterSearch').serialize(), {
        sort_by:      sort_by,
        sort_order:   sort_order,
        page:         page,
        view:         current_view,
    });
}
-->

$(document).ready(function()
{
	<?php 
		if (isset($notify) && $notify != "")
		{
			if ($notify == "editSuccess")
			{
				$type = "success";
				$title = "Thông báo";
				$text = "Bạn đã chỉnh sửa danh mục bài viết thành công.";
				$icon = "picon icon16 brocco-icon-info white";
			} else if ($notify == "delSuccess")
			{
				$type = "success";
				$title = "Thông báo";
				$text = "Bạn đã xóa danh mục bài viết thành công.";
				$icon = "picon icon16 brocco-icon-info white";
			} else if ($notify == "delFailed")
			{
				$type = "error";
				$title = "Thông báo";
				$text = "Lỗi xảy ra trong quá trình xóa danh mục. Vui lòng thử lại sau";
				$icon = "picon icon24 typ-icon-cancel white";
			} 
			?>
			$.pnotify({
				type: '<?=$type?>',
			    title: '<?=$title?>',
	    		text: '<?=$text?>',
			    icon: '<?=$icon?>',
			    opacity: 0.95,
			    history: false,
			    sticker: false
			});
			<?
		}
	?>
});
-->
</script>
<div class="row-fluid">
    <div class="span12">
        <div class="box">
            <div class="title">
                <h4>
                    <span class="icon16 brocco-icon-grid"></span>
                    <span>Danh mục</span>
                </h4>
            </div>
            <div class="content" id="SearchForm">
                <form class="form-horizontal" id="cms_category_validate" action="<?php echo url_for('@cms_category_list') ?>" method="post" />
                    <div class="form-row row-fluid">
                        <div class="span8">
                            <div class="row-fluid">
                                <?php echo $cms_category_form['parent_id']->renderLabel(null, array("class"=>"form-label span3"));  ?>
                                <div class="span8 controls">
                                	<?php echo $cms_category_form['parent_id']->render(array("class" => "nostyle", "style" => "width:100%", "id" => "cms_category_parent"));  ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-row row-fluid">
                        <div class="span8">
                            <div class="row-fluid">
                                <?php echo $cms_category_form['alias']->renderLabel(null, array("class"=>"form-label span3"));  ?>
                                <div class="span8 controls">
                                	<?php echo $cms_category_form['alias']->render(array("id" => "cms_category_alias"));  ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-row row-fluid">
                        <div class="span8">
                            <div class="row-fluid">
                                <?php echo $cms_category_form['name']->renderLabel(null, array("class"=>"form-label span3"));  ?>
                                <div class="span8 controls">
                                	<?php echo $cms_category_form['name']->render(array("id" => "cms_category_name"));  ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-row row-fluid">
                        <div class="span8">
                            <div class="row-fluid">
                                <?php echo $cms_category_form['name_vi']->renderLabel(null, array("class"=>"form-label span3"));  ?>
                                <div class="span8 controls">
                                	<?php echo $cms_category_form['name_vi']->render(array("id" => "cms_category_name"));  ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-row row-fluid">
                        <div class="span8">
                            <div class="row-fluid">
                                <?php echo $cms_category_form['position']->renderLabel(null, array("class"=>"form-label span3"));  ?>
                                <div class="span8 controls">
                                	<?php echo $cms_category_form['position']->render(array("id" => "cms_category_position"));  ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php
					/***    Template and Module Type
					
                    <div class="form-row row-fluid">
                        <div class="span8">
                            <div class="row-fluid">
                                <?php echo $cms_category_form['cms_type']->renderLabel(null, array("class"=>"form-label span3"));  ?>
                                <div class="span8 controls">
                                    <?php echo $cms_category_form['cms_type']->render(array("class" => "nostyle", "style" => "width:100%", "id" => "cms_category_type"));  ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-row row-fluid">
                        <div class="span8">
                            <div class="row-fluid">
                                <?php echo $cms_category_form['template']->renderLabel(null, array("class"=>"form-label span3"));  ?>
                                <div class="span8 controls">
                                    <?php echo $cms_category_form['template']->render(array("class" => "nostyle", "style" => "width:100%", "id" => "cms_category_template"));  ?>
                                </div>
                            </div>
                        </div>
                    </div>
					*/
					?>
					<?php echo $cms_category_form['_csrf_token'];  ?>
                    <div class="form-row row-fluid">                              
                        <div class="span8">
                            <div class="row-fluid">
                                <div class="form-actions">
                                    <div class="span3"></div>
                                    <div class="span8 controls">
                                        <button type="submit" class="btn marginR10" name="create" value="Create">Lưu</button>
                                        <button class="btn btn-danger">Làm lại</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php if (isset($create_success) || isset($is_create_action)) : ?>
                    <div class="form-row row-fluid">
                        <div class="span12">
                            <div class="row-fluid">
                                <?php if (isset($create_success) && $create_success): ?>
                                    <div class="alert alert-success">Danh mục đã tạo thành công</div>
                                    <script>
                                        window.location.href = document.location.href;
                                    </script>
                                <?php elseif (isset($create_success) && $create_success == false): ?>
                                    <div class="alert alert-error">Danh mục đã tồn tại</div>
                                    <script>
                                        window.location.href = document.location.href;
                                    </script>
                                <?php elseif (isset($is_create_action)) :?>
                                    <div class="alert alert-error">Danh mục không đúng</div>
                                    <script>
                                        window.location.href = document.location.href;
                                    </script>
								<?php endif ?>
							</div>
						</div>
					</div>
                    <?php endif ?>
  				</form>
			</div>
		</div>
	</div>
</div>
<div style='padding-top:10px;'>
    <div class="UITable">
      <div id="indexAjax" class='filter_form'>
        <?php include 'categoryListAjax.php' ?>
      </div>
    </div>
</div>